#include "decryption_oneround.h"
#include <stdio.h>

void decryption_oneround( word* state , int r , word* S )
{
	parallel_right_move( &state[0] , &state[1] , &state[2] , &state[3] ) ;
	
	word u , t ; 
	u = rotate_left( state[3] * (2*state[3] + 1) , LG_RC6_KEY_WORD ) ;
	t = rotate_left( state[1] * (2*state[1] + 1) , LG_RC6_KEY_WORD ) ;
	state[2] = (rotate_right( (state[2] - S[2*r+1]) , last_five_bit( t ) ))^ u ;
	state[0] = (rotate_right( (state[0] - S[2*r] ) , last_five_bit( u ) )) ^ t ;
	for ( int i = 0 ; i <= 3 ; ++i )
	{
		printf( "%x " , state[i] ) ;
	}
	printf( "\n" ) ;
}